/**
 * Created by kiwi on 16/12/22.
 */
'use strict';
import React, { Component } from 'react';
import {
  AppRegistry,
  TabBarIOS,
  StyleSheet,
  Text,
  View
} from 'react-native';
import {selectTab,navigationTab} from './actions/index';
import { connect } from 'react-redux';

var base64Icon = '';

class TabBar extends Component {
  constructor(props, context) {
    super(props, context);
  }
  render() {
    return (
      <TabBarIOS
        unselectedTintColor="yellow"
        tintColor="white"
        barTintColor="darkslateblue">
        <TabBarIOS.Item
          title="Blue Tab"
          icon={{uri: base64Icon, scale: 3}}
          selected={this.props.selectedTab === 'tab1'}
          onPress={() => {this.props.switchTab(selectTab('tab1'))}}>
          <View><Text>safdsaf</Text></View>
        </TabBarIOS.Item>
        <TabBarIOS.Item
          systemIcon="history"
          badge={2}
          selected={this.props.selectedTab === 'tab2'}
          onPress={() => {this.props.switchTab(selectTab('tab2'))}}>
          <View></View>
        </TabBarIOS.Item>
        <TabBarIOS.Item
          icon={{uri: base64Icon, scale: 3}}
          selectedIcon={{uri: base64Icon, scale: 1}}
          renderAsOriginal
          title="More"
          selected={this.props.selectedTab === 'tab3'}
          onPress={() => {this.props.switchTab(selectTab('tab3'))}}>
          <View></View>
        </TabBarIOS.Item>
      </TabBarIOS>
    );
  }
}

const mapStateToProps = (state) => {
  return {
    selectedTab: state.selectedTab
  }
};
const mapDispatchToProps = (dispatch) => {
  return {
    switchTab: (tab) => {
      dispatch(tab)
    }
  }
};
TabBar = connect(mapStateToProps,mapDispatchToProps)(TabBar);
export default TabBar;